export default {
	isJiess: true,
	name: 'Custom',
	setup({ midder, hook, Tree }) {
		const { columns = [] } = midder.proxy;
		const gData = hook.$m.$ref([...columns]);
		this.add({
			draggable: true,
			is: Tree,
			'node-key': 'key',
			'show-checkbox': true,
			data: { $proxy: gData },
			'default-checked-keys': columns.filter((o) => !o.hidden).map((o) => o.key),
			onNodeDrop(draggingNode, dropNode, dropType, ev) {
				midder.proxy.columns = [...gData.value];
			},
			onCheck(_, { checkedKeys }) {
				midder.proxy.columns = columns.map((o) => {
					o.hidden = !checkedKeys.includes(o.key);
					return o;
				});
			},
			allowDrop(draggingNode, dropNode, type) {
				return type !== 'inner';
			},
			allowDrag(draggingNode) {
				return draggingNode.label !== '操作';
			}
		})
	}
};